package com.eric.rabbitmq.work.lunxun;


import com.eric.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

public class Producers {
    //队列名称
    public static  final  String QUEUE_NAME = "hello";
    //发消息
    public static void main(String[] args) throws Exception{
        Channel channel = RabbitMqUtils.getChannel();
        //生成队列
        channel.queueDeclare(QUEUE_NAME, false,false,false,null);
        //发消息
        //接收输入消息
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String message = scanner.next();
            channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
            System.out.println("消息发送完毕");
        }
    }
}
